]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
screenshot: Snap cursor to the center of the handle on press
authorRamez Medhat <iramezdev@gmail.com>
Sat, 28 Mar 2026 15:14:15 +0000 (17:14 +0200)
committerMarge Bot <marge-bot@gnome.org>
Wed, 15 Apr 2026 19:42:25 +0000 (19:42 +0000)
When dragging the screenshot area handle from the outer sides, it is
currently impossible to move them to the edges or corners of the screen,
as the cursor is constrained to the monitor.

Fix this by snapping the cursor to the center of the handle when starting
the resize operation.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/9113
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/4158>

js/ui/screenshot.js

index e0ec8b76acd8c95dc0423e00ac05dacc09ba8a6d..499baa8f4590e9190dae8819920af31a31bd5f3d 100644 (file)
@@ -481,6 +481,44 @@ const UIAreaSelector = GObject.registerClass({
             const rightX = leftX + width - 1;
             const bottomY = topY + height - 1;
 
+            let snapX = this._dragStartX;
+            let snapY = this._dragStartY;
+
+            switch (cursor) {
+            case Clutter.CursorType.NW_RESIZE:
+                snapX = leftX;
+                snapY = topY;
+                break;
+            case Clutter.CursorType.NE_RESIZE:
+                snapX = rightX;
+                snapY = topY;
+                break;
+            case Clutter.CursorType.SW_RESIZE:
+                snapX = leftX;
+                snapY = bottomY;
+                break;
+            case Clutter.CursorType.SE_RESIZE:
+                snapX = rightX;
+                snapY = bottomY;
+                break;
+            case Clutter.CursorType.N_RESIZE:
+                snapY = topY;
+                break;
+            case Clutter.CursorType.S_RESIZE:
+                snapY = bottomY;
+                break;
+            case Clutter.CursorType.W_RESIZE:
+                snapX = leftX;
+                break;
+            case Clutter.CursorType.E_RESIZE:
+                snapX = rightX;
+                break;
+            }
+
+            const backend = this.get_context().get_backend();
+            backend.get_default_seat().warp_pointer(snapX, snapY);
+            [this._dragStartX, this._dragStartY] = [snapX, snapY];
+
             // For moving, start X and Y are the top left corner, while
             // last X and Y are the bottom right corner.
             if (cursor === Clutter.CursorType.MOVE) {